package com.yy.okhttp;

import java.util.ArrayList;
import java.util.List;

/**
 * User: gongyongfeng2@yy.com
 * Date: 2020/7/27 15 :47
 */
public class YYOkHttpClient {
    private Dispatcher dispatcher;
    private ConnectionPoll connectionPoll;
    private List<Interceptor> interceptors;
    private int retrys;

    public YYOkHttpClient() {
        this(new Builder());
    }

    public YYOkHttpClient(Builder builder) {
        dispatcher = builder.dispatcher;
        connectionPoll = builder.connectionPoll;
        interceptors = builder.interceptors;
        retrys = builder.retrys;
    }

    public ConnectionPoll getConnectionPoll() {
        return connectionPoll;
    }

    public int reTry(){
        return retrys;
    }

    public List<Interceptor> interceptors() {
        return interceptors;
    }

    public static class Builder {
        private Dispatcher dispatcher = new Dispatcher();
        private ConnectionPoll connectionPoll = new ConnectionPoll();
        private List<Interceptor> interceptors = new ArrayList<>();
        private int retrys;

        public List<Interceptor> getInterceptors() {
            return interceptors;
        }

        public void setInterceptors(List<Interceptor> interceptors) {
            this.interceptors = interceptors;
        }

        public int getRetrys() {
            return retrys;
        }

        public void setRetrys(int retrys) {
            this.retrys = retrys;
        }
    }

    public Call newCall(Request request) {
        return new Call(this, request);
    }

    public Dispatcher dispatcher() {
        return dispatcher;
    }
}
